package com.cskaoyan.controller.front.comment;

import com.cskaoyan.bean.bo.front.Comment.CommentSendBO;
import com.cskaoyan.bean.po.BasePageInfo;
import com.cskaoyan.bean.po.CommonData;
import com.cskaoyan.bean.po.MarketUser;
import com.cskaoyan.bean.vo.back.BaseRespVo;
import com.cskaoyan.bean.vo.front.comment.CommentCountVO;
import com.cskaoyan.bean.vo.front.comment.CommentSendVo;
import com.cskaoyan.service.front.comment.WxCommentService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @author: jzc
 * @since: 2022/10/15 14:37
 **/
@RestController
@RequestMapping("wx/comment")
public class WxCommentController {

    @Autowired
    WxCommentService wxCommentService;
    @GetMapping("list")
    public BaseRespVo commentList(BasePageInfo basePageInfo,Integer valueId,Boolean showType,Byte type){
        CommonData commonData=wxCommentService.getCommentList(basePageInfo,valueId,type,showType);
        return BaseRespVo.ok(commonData);
    }
    @GetMapping("count")
    public BaseRespVo commentList(Integer valueId,Byte type){
        CommentCountVO commentCountVO=wxCommentService.getCommentCount(valueId,type);
        return BaseRespVo.ok(commentCountVO);
    }
    @PostMapping("post")
    public BaseRespVo sendComment(@RequestBody CommentSendBO commentSendBO){
        MarketUser primaryPrincipal = (MarketUser) SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal();
        CommentSendVo commentSendVo=wxCommentService.SendComment(commentSendBO,primaryPrincipal);
        return BaseRespVo.ok(commentSendVo);
    }
}
